package org.example.smartEducationBackend.controller;

import org.example.smartEducationBackend.entity.POJO.Favorite;
import org.example.smartEducationBackend.entity.POJO.RestResult;
import org.example.smartEducationBackend.service.FavoriteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@RestController
@RequestMapping("/favorite")
public class FavoriteController {
    @Autowired
    private FavoriteService favoriteService;
    @GetMapping("/getFavorite")
    public RestResult<Favorite> getFavorite(@RequestParam Integer userId, @RequestParam Integer videoId ){

        Favorite favorite1 = favoriteService.getFavorite(userId,videoId);

        return RestResult.ok(favorite1);
    }
    @PostMapping("/add")
    private RestResult<String> add(@RequestBody Favorite favorite){
        favorite.setCreateTime(new Date());

        favoriteService.add(favorite);

        return RestResult.ok("success");

    }
@PostMapping("/delete")
    private RestResult<String> delete(@RequestBody Favorite favorite){
        favoriteService.delete(favorite);


        return RestResult.ok("success");

    }



}
